package com.example.sxt_practise.IO;

import org.apache.commons.io.FileUtils;
import org.apache.commons.io.filefilter.DirectoryFileFilter;
import org.apache.commons.io.filefilter.EmptyFileFilter;
import org.apache.commons.io.filefilter.FileFilterUtils;
import org.apache.commons.io.filefilter.SuffixFileFilter;

import java.io.File;
import java.util.Collection;

/**
 * @author gaofeng
 * @date 2022年05月12日 1:25
 */
public class CommonsIoTest {
    public static void main(String[] args) {
        File file = new File("src") ;
        System.out.println(FileUtils.sizeOf(file));
        File txt = new File("src/IO/print.txt") ;
        System.out.println(FileUtils.sizeOf(txt));

        Collection<File> files = FileUtils.listFiles(new File("src"), EmptyFileFilter.NOT_EMPTY, DirectoryFileFilter.DIRECTORY);
        for (File file1 : files) {
            System.out.println(file1.getAbsolutePath());
        }

        System.out.println("*************************************************************");

        Collection<File> files1 = FileUtils.listFiles(new File("src/IO"), FileFilterUtils.and(EmptyFileFilter.NOT_EMPTY,new SuffixFileFilter("java"), new SuffixFileFilter("class")), DirectoryFileFilter.INSTANCE);
        for (File file1 : files1) {
            System.out.println(file1.getAbsolutePath());
        }
    }
}
